#include "tcpServer.hpp"
#include "log.hpp"

#include "daemon.hpp"
#include <iostream>

#include <string>
#include <memory>

using namespace std;
using namespace Server;

static void Usage(string proc)
{
    cout << "\nUsage:\n\t" << proc << " local_port\n\n"
         << endl;
    exit(USAGE_ERR);
}

//.tcpServer tcpport
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        Usage(argv[0]);
    }
    uint16_t port = atoi(argv[1]);
    unique_ptr<TcpServer> tsvr(new TcpServer(port));
    tsvr->initServer();
    daemonSelf();

    tsvr->start();
    return 0;
}
